package logic

import (
	"context"
	"user_srv/internal/dao"
	"user_srv/internal/svc"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type RetroactiveSignInLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewRetroactiveSignInLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RetroactiveSignInLogic {
	return &RetroactiveSignInLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *RetroactiveSignInLogic) RetroactiveSignIn(in *user.RetroactiveSignInRequest) (*user.SignInResponse, error) {

	success, points, message, err := dao.RetroactiveSign(in.UserId) // 调用dao层的补签函数
	if err != nil {
		return nil, err
	}
	return &user.SignInResponse{
		Success: success,
		Points:  points,
		Message: message,
	}, nil
}
